<!-- case包 -->
<template>
    <div class="casepackage" v-loading="loading">
        <!-- 表格 -->
        <dy-table :elTable_Options="elTable_Options" @handleClick="handleClick" @bottonHandle="bottonHandle"
            @handleSelect="handleSelect" ref="table" />
    </div>
</template>

<script setup>
import { reactive, toRefs, ref, onMounted, nextTick } from 'vue'
import { useRouter, useRoute } from 'vue-router'

const router = useRouter()

//数据
let state = reactive({
    loading: false
})
let { loading } = toRefs(state)

//实例
let table = ref(null)

//所有展示的数据
let allConfigList = [{
    label: "标准试验包名称",
    prop: "standard_task_name",
    columType: 'linkTo',
},
{
    label: "所属部门/科室",
    prop: "sy_owndeptid",
    columType: 'arrayKey',
    keyName: 'department_name',
},
{
    label: "包含case数量",
    prop: "case_num",
    columType: 'text',
},
{
    label: "创建人",
    prop: "creater",
    columType: 'arrayKey',
    keyName: "real_name"
},
{
    label: "总需求占用台时(h)",
    prop: "all_occupy_hour",
    columType: 'text',
    width: 160
},
{
    label: "描述",
    prop: "description",
    columType: 'text'
}]

//表格数据
let elTable_Options = reactive({
    pagename: '台架试验CASE包', //页面名称
    selection: false, //true 单选
    allConfigList: allConfigList, //需要配置项就加 不需要可以不写
    eltableArr: allConfigList, //表头数据
    table_type: "casepackage_试验CASE包", //列表配置喜好 和 allConfigList一起
    getwayname: 'casepackage', //接口名
    // ifturnpage: 是否展示分页 
    //按钮
    opbutton: [{
        label: '新增case包',
        dealway: 'createdata',
        icon: 'Plus',
        type: "primary",
        keyV: "add",
        disabled: false
    }, {
        label: "批量删除",
        dealway: "asysdeleterow",
        icon: 'Delete',
        type: "danger",
        keyV: "delete",
        disabled: false
    }],
    //查询栏
    searchList: [{
        label: "搜索标准试验包名称",
        key: "search",
        searchtype: 'input',
        width: 330
    },
    {
        label: "创建人",
        key: "creater_name",
        searchtype: 'input'
    },
    {
        label: "所属科室",
        key: "sy_owndeptid", //级联选择器
        searchtype: 'Cascader',
        width: 240,
        options: [],
        props: {
            checkStrictly: true,
            value: "id",
            label: "department_name",
        }
    }]
})

onMounted(() => {
    gettabledata()
})

//获取数据
let gettabledata = (row) => {
    nextTick(() => {
        table.value.getTableData(row)
    })
}

//链接点击
let handleClick = (row, index) => {
    if (index == '3') {
        router.push({
            path: '/syStandardLib/casepackage/view/' + row.id
        })
    }
}

//按钮点击
let bottonHandle = (wayname) => {
    if (wayname == 'createdata') {
        //新增
        router.push({
            path: '/syStandardLib/casepackage/create'
        })
    }
}

//切换tab
let handleSelect = (key) => {
    elTable_Options.menuname = key
    nextTick(() => {
        table.value.conditional()
    })
}

</script>

<style lang="scss" scoped></style>